<?php

/**
 * This is the model class for table "{{email}}".
 *
 * The followings are the available columns in table '{{email}}':
 * @property integer $zem_id
 * @property integer $zm_id
 * @property string $zem_type
 * @property integer $zet_id
 * @property string $zem_keyword
 * @property string $zem_email
 * @property integer $zem_status
 * @property string $zem_key
 * @property integer $inputtime
 */
class Email extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Email the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{email}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zm_id, zet_id, zem_keyword, zem_email, zem_key, inputtime', 'required'),
			array('zm_id, zet_id, zem_status, inputtime', 'numerical', 'integerOnly'=>true),
			array('zem_type', 'length', 'max'=>1),
			array('zem_keyword, zem_email', 'length', 'max'=>50),
			array('zem_key', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zem_id, zm_id, zem_type, zet_id, zem_keyword, zem_email, zem_status, zem_key, inputtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zem_id' => 'Zem',
			'zm_id' => 'Zm',
			'zem_type' => 'Zem Type',
			'zet_id' => 'Zet',
			'zem_keyword' => 'Zem Keyword',
			'zem_email' => 'Zem Email',
			'zem_status' => 'Zem Status',
			'zem_key' => 'Zem Key',
			'inputtime' => 'Inputtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zem_id',$this->zem_id);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zem_type',$this->zem_type,true);
		$criteria->compare('zet_id',$this->zet_id);
		$criteria->compare('zem_keyword',$this->zem_keyword,true);
		$criteria->compare('zem_email',$this->zem_email,true);
		$criteria->compare('zem_status',$this->zem_status);
		$criteria->compare('zem_key',$this->zem_key,true);
		$criteria->compare('inputtime',$this->inputtime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}